package com.lmt.repository;

import com.lmt.entity.ResourceDownload;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

/**
 * Date 2018/07/17
 *
 * @author MT-Lin
 */
@Repository
public interface ResourceDownloadRepository extends JpaRepository<ResourceDownload, String> {

	/**
	 * 根据资源ID和用户ID查找下载记录
	 * @param resourceId 资源ID
	 * @param userId 用户ID
	 * @return ResourceDownload
	 */
	ResourceDownload findByResourceIdAndUserId(String resourceId, String userId);

	/**
	 * 获取用户的下载次数
	 * @param userId 用户ID
	 * @return 下载次数
	 */
	int countByUserId(String userId);
}
